# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=qt5-qt3d
pkgver=5.15.10_git20230424
pkgrel=0
_module="${pkgname#qt5-}"
_pkgver=01aa0a9cb22ce5ed2b7ead03ed9cbeb5f978e897
_fullname=$_module-$_pkgver
pkgdesc="C++ and QML APIs for easy inclusion of 3D graphics"
url="https://www.qt.io/developers/"
license="LGPL-2.1-only AND LGPL-3.0-only AND GPL-3.0-only AND Qt-GPL-exception-1.0"
# armhf blocked by qt5-qtdeclarative
arch="all !armhf"
makedepends="
	assimp-dev
	qt5-qtbase-dev
	qt5-qtdeclarative-dev
	vulkan-headers
	"
subpackages="$pkgname-dev"

source="https://dev.alpinelinux.org/archive/qt/$_fullname.tar.xz"
builddir="$srcdir/$_fullname"

_disturl="dev.alpinelinux.org:/archive/qt/"
snapshot() {
	clean
	makedepends="git xz rsync tar" deps
	mkdir -p "$srcdir" && cd "$srcdir"
	git clone --filter=tree:0 https://invent.kde.org/qt/qt/$_module.git .
	git archive --format tar --prefix=$_fullname/ $_pkgver > "$SRCDEST"/$_fullname.tar
	xz -vv -T0 -9 -e "$SRCDEST"/$_fullname.tar
	rsync --progress -La "$SRCDEST"/$_fullname.tar.xz $_disturl
}

prepare() {
	default_prepare

	# We need to make the build system think we're running in a git repository
	# so it correctly symlinks during the build
	mkdir .git
}

build() {
	qmake-qt5
	make
}

check() {
	make check
}

package() {
	make INSTALL_ROOT="$pkgdir" install

	# Drop QMAKE_PRL_BUILD_DIR because reference the build dir
	find "$pkgdir/usr/lib" -type f -name '*.prl' \
		-exec sed -i -e '/^QMAKE_PRL_BUILD_DIR/d' {} \;
}

sha512sums="
a662b7259b0cc5a1b985fc9089bf1b0f33b71268aaa6604d00e229a94b0592ccc8fb775a6957d16ad56cc7906396dbd5eb81e0f9139bdf42bb66d61fa9cea2a6  qt3d-01aa0a9cb22ce5ed2b7ead03ed9cbeb5f978e897.tar.xz
"
